
import java.util.*;
public class Solution
{
    int n;
    boolean[] vis = new boolean[210];
    public int citys (ArrayList<ArrayList<Integer>> m) {
        n = m.size();
        int ret = 0;
        for(int i = 0; i < n; i++) {
            if(vis[i] == false) {
                ret++;
                dfs(m, i);
            }
        }
        return ret;
    }
    public void dfs(ArrayList<ArrayList<Integer>> m, int pos)
    {
        vis[pos] = true;
        for(int i = 0; i < n; i++) {
            if(m.get(pos).get(i) == 1 && vis[i] == false) {
                dfs(m, i);
            }
        }
    }
}

